package controlLayer;
import modelLayer.LoanContainer;
import modelLayer.Loan;
import modelLayer.Person;
import modelLayer.DVD;
import modelLayer.Copy;

public class LoanCtr {
    private LoanContainer loanContainer;

    /**
     * Get the LoanContainer instance.
     */
    public LoanCtr() {
        loanContainer = LoanContainer.getInstance();
    }

    public void createLoan(String borrowDate, String period, Person p, Copy c) {
        Loan l = new Loan(borrowDate, period, p, c);
        c.makeBorrowed();
        loanContainer.addLoan(l);
    }
    
    
      /**
     * Get a Loan object by a given ID.
     * @param ID The ID of the desired loan
     */
    public Loan findLoan(int ID) {
        return loanContainer.getLoan(ID);
    }
    
    /**
     * Extend the period of the desired loan with a given new period
     * @param ID The ID of the desired loan to get his peiod updated.
     * @param newPeriod The new period of the loan.
     */
    public void extendLoan(int ID, String period) {
        loanContainer.extendLoan(ID, period);
    }
    
    /**
     * Delete the desired loan by a given ID.
     * @param ID The ID of the loan.
     */
    public void deleteLoan(int ID) {
        loanContainer.deleteLoan(ID);
    }
    
     /**
     * Change the status of a loan
     * @param ID The ID of a loan to be completed
     */
    public void completeLoan(int ID) {
        loanContainer.completeLoan(ID);
    }
}
